﻿using System.Configuration;

namespace Gamemaster.Naming
{
    public class LinqDatabaseFactory : INameDatabaseFactory
    {
        public INameDatabase CreateDatabase()
        {
            if (ConfigurationManager.ConnectionStrings["naming"] != null)
            {
                string connection = ConfigurationManager.ConnectionStrings["naming"].ConnectionString;

                return new LinqNameDatabase(connection);
            }
            else
            {
                throw new ConfigurationErrorsException("connection string for [naming] database is not configured");
            }
        }

        public static bool ConfigurationExists()
        {
            return ConfigurationManager.ConnectionStrings["naming"] != null;
        }
    }
}
